#include <bits/stdc++.h>

using namespace std;

int main_39_2()
{
    int n,N;
    long long sumA=0;
    scanf("%d%d",&n,&N);
    int A_arr[n+2]={0};
    for (int i=1;i<=n ;++i )
    {
        scanf("%d",&A_arr[i]);
    }
    A_arr[n+1]=N;
    for (int i=0;i<n+1 ;++i )
    {
        int pos=upper_bound(A_arr,A_arr+n+2,A_arr[i])-A_arr-1;
        sumA+=pos*(A_arr[i+1]-A_arr[i]);
    }
    printf("%lld",sumA);
    return 0;
}
